package net.patterer.db;

import java.sql.Connection;
import java.sql.Statement;

import org.apache.derby.jdbc.EmbeddedDataSource;

public class DatabaseTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		createDatabase();
		
	}

	public static void createDatabase() {

		try {

			EmbeddedDataSource ds = new EmbeddedDataSource();

	        ds.setCreateDatabase("create");
	        ds.setDatabaseName("ChrisDb");
	        
	        Connection conn = ds.getConnection();
			Statement stmt = conn.createStatement();
			stmt.execute("create table TestTable(ID int primary key, FIRSTNAME varchar(40), SURNAME varchar(40))");
			stmt.execute("insert into TestTable values (1, 'Joe', 'Bloggs')");
			stmt.execute("insert into TestTable values (2, 'Jane', 'Doe')");
			stmt.execute("insert into TestTable values (3, 'John', 'Smith')");
			
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}
